﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Linguist.Language.NGram.Large
{
    /// <summary>
    /// Represents a probability, a backoff probability, and the location of the first bigram entry. 
    /// </summary>
    public class UnigramProbability
    {
        private int wordID;
        private float logProbability;
        /// <summary>
        /// the log probability of this unigram
        /// </summary>
        public float LogProbability
        {
            get { return logProbability; }
            set { logProbability = value; }
        }
        private float logBackoff;
        private int firstBigramEntry;


        /**
        /// Constructs a UnigramProbability
         *
        /// @param wordID           the id of the word
        /// @param logProbability   the probability
        /// @param logBackoff       the backoff probability
        /// @param firstBigramEntry the first bigram entry
         */
        public UnigramProbability(int wordID, float logProbability,
                                  float logBackoff, int firstBigramEntry) 
        {
            this.wordID = wordID;
            this.logProbability = logProbability;
            this.logBackoff = logBackoff;
            this.firstBigramEntry = firstBigramEntry;
        }


        /**
        /// Returns a string representation of this object
         *
        /// @return the string form of this object
         */
        override
        public String ToString() 
        {
            return "Prob: " + LogProbability + ' ' + logBackoff;
        }


        /**
        /// Returns the word ID of this unigram
         *
        /// @return the word ID of this unigram
         */
        public int getWordID() 
        {
            return wordID;
        }

        /**
        /// Returns the log backoff weight of this unigram
         *
        /// @return the log backoff weight of this unigram
         */
        public float getLogBackoff() 
        {
            return logBackoff;
        }


        /**
        /// Returns the index of the first bigram entry of this unigram.
         *
        /// @return the index of the first bigram entry of this unigram
         */
        public int getFirstBigramEntry() 
        {
            return firstBigramEntry;
        }

        /**
        /// Sets the log backoff weight.
         *
        /// @param logBackoff the new log backoff weight
         */
        public void setLogBackoff(float logBackoff) 
        {
            this.logBackoff = logBackoff;
        }

    }
}
